//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using CommunityServer.Blogs.Components;

namespace CommunityServer.Components.SearchBarrel
{
    public class WeblogBarrelItem : BarrelItem
    {
        public override void Format(IndexPost post)
        {
            WeblogPost wp = new WeblogPost();
            wp.PostID = post.PostID;
            wp.Name = post.Name;
            wp.UserTime = post.PostDate;
            wp.SectionID = post.SectionID;

            WeblogPost weblogPost = WeblogPosts.GetWeblogEntry(wp.SectionID, wp.PostID);

			if (weblogPost.BlogPostType != BlogPostType.Comment)
				post.Url = BlogUrls.Instance().Post(wp);
			else
			{
				wp.BlogPostType = weblogPost.BlogPostType;
				wp.ParentID = weblogPost.ParentID;
				post.Url = BlogUrls.Instance().Post(wp, wp.Weblog, weblogPost);
			}

            post.ApplicationUrl = BlogUrls.Instance().Home;
        }

        public override ApplicationType ApplicationType
        {
            get
            {
                return ApplicationType.Weblog;
            }
        }

    }
}